<?php
namespace app\common\model;

trait BaseSubmitter {
  //protected $foreignKey;

  public function setSubmitterIdAttr($value) {
    if (!$value) {
      return $GLOBALS['userInfo']['uid'];
    } else {
      return $value;
    }
  }
  public function setSubmitterTimeAttr($value) {
    if (!$value) {
      return time();
    } else {
      return $value;
    }
  }

  public function getSubmitterAttr($value, $data) {
    if ($data['submitter_id'])
      return model('admin/AdminUser')->where('id',$data['submitter_id'])->value('real_name');
    else
      return null;
  }

  public function getSubmitterTimeAttr($value) {
    return date('Y-m-d h:i:s',$value);
  }

}